package solutions.leetcode.easy

/**
 * @author lizhidong
 * <a href="https://leetcode.cn/problems/odd-string-difference/">2451. 差值数组不同的字符串</a>
 */
private class Solution2451 {
    fun oddString(words: Array<String>): String {
        val map = HashMap<String, Pair<String, Int>>()
        for (item in words) {
            val sb = StringBuilder()
            for (i in 0 until item.length - 1) {
                sb.append(item[i] - item[i + 1]).append(',')
            }
            map[sb.toString()] = Pair(item, map.getOrDefault(sb.toString(), Pair("", 0)).second + 1)
        }
        for (item in map) {
            if (item.value.second == 1) {
                return item.value.first
            }
        }
        return ""
    }
}


fun main() {
    println(Solution2451().oddString(
        arrayOf(
            "adc","wzy","abc"
        )
    ))
}